﻿using System;
using System.ComponentModel;

using SharpGL.Media3D;

namespace SharpGL.SceneGraph.Primitives.SmartAxies
{
    [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
    public class AxisName : AxisCaption2D
    {
        #region Private Fields

        private Vector3D shift = new Vector3D(0.0f, 0.0f, 0.0f);

        #endregion Private Fields

        #region Public Constructors

        public AxisName()
        {
        }

        #endregion Public Constructors

        #region Internal Methods

        internal void Render(OpenGL gl, Point3D position)
        {
            if (!OpenGL.IsValidContext(gl))
                throw new ArgumentException();

            if (Visible)
            {
                gl.Color(Color);
                position.Push(shift);
                TextObject.Position = position;
                TextObject.Render(gl, RenderMode.Render);
            }
        }

        #endregion Internal Methods

        #region Public Properties

        [Description("Caption"), Category("Axis name")]
        public string Caption
        {
            get { return TextObject.Text; }
            set
            {
                if (TextObject.Text != value)
                {
                    if (value != null)
                        TextObject.Text = value;
                    else
                        TextObject.Text = "";

                    NotifyPropertyChanged("Caption");
                }
            }
        }

        [Description("Shift"), Category("Axis name")]
        public Vector3D Shift
        {
            get { return shift; }
            set
            {
                if (shift != value)
                {
                    shift = value;

                    NotifyPropertyChanged("Shift");
                }
            }
        }

        #endregion Puclic Properties
    }
}
